home *** CD-ROM | disk | FTP | other *** search
/ Workbench Add-On / Workbench Add-On - Volume 1.iso / Dev / PHX / PhxAss / Examples / vbr.asm < prev    next >
Assembly Source File  |  1995-08-26  |  3KB  |  155 lines

  1. **
  2. **    VBR - Revision 2
  3. ** Switches the Vector Base to
  4. **    Chip- or Fast-RAM
  5. **
  6. **  Coded by Frank Wille 1994
  7. **
  8. **   Assembler: PhxAss V4.xx
  9. **
  10.  
  11.     machine 68010            ; 'cause of VBR
  12.  
  13.     incdir    "include"
  14. **  You should also define an include path for your Commodore **
  15. ** includes or make use of the PHXASSINC environment variable **
  16.     include "lib/exec.i"
  17.     include "lib/dos.i"
  18.     include "exec/execbase.i"
  19.     include "exec/memory.i"
  20.  
  21. VBR_SIZE    = $400            ; size of vector base area in bytes
  22.  
  23.  
  24.  
  25.     code
  26.  
  27.  
  28.     move.l    ExecBase.w,a6
  29.     lea    DosName(pc),a1
  30.     moveq    #37,d0
  31.     jsr    OpenLibrary(a6)     ; open dos.library (OS2.04)
  32.     tst.l    d0
  33.     beq    error
  34.     move.l    d0,a4            ; a4 DOSBase
  35.     moveq    #0,d6            ; d6 Quiet-Flag
  36.     moveq    #0,d7            ; d7 VBR-Flag (1=Zero, -1=Fast)
  37.     exg    a4,a6
  38.     lea    cmd_template(pc),a0
  39.     move.l    a0,d1
  40.     clr.l    -(sp)
  41.     clr.l    -(sp)
  42.     clr.l    -(sp)
  43.     move.l    sp,d2
  44.     moveq    #0,d3
  45.     jsr    ReadArgs(a6)
  46.     move.l    d0,d1            ; ReadArgs-Error?
  47.     bne.s    1$
  48.     lea    12(sp),sp
  49.     jsr    IoErr(a6)
  50.     move.l    d0,d1
  51.     moveq    #0,d2
  52.     jsr    PrintFault(a6)        ; print error message
  53.     exg    a4,a6
  54.     bra    exit
  55. 1$:    jsr    FreeArgs(a6)
  56.     tst.l    (sp)+            ; VBR ZERO?
  57.     beq.s    2$
  58.     moveq    #1,d7            ; d7 Zero-VBR
  59.     addq.l    #4,sp
  60.     bra.s    3$
  61. 2$:    tst.l    (sp)+            ; VBR FAST?
  62.     sne    d7
  63. 3$:    tst.l    (sp)+            ; QUIET-Mode?
  64.     sne    d6
  65.     exg    a4,a6
  66.     moveq    #0,d5
  67.     move.b    AttnFlags+1(a6),d0    ; which processor is installed?
  68.     moveq    #3,d1
  69. 4$:    lsr.b    #1,d0
  70.     bcc.s    5$
  71.     add.w    #10,d5
  72.     dbf    d1,4$
  73.     tst.b    AttnFlags+1(a6)     ; 68060?
  74.     bpl.s    5$
  75.     add.w    #20,d5
  76. 5$:    sub.l    a2,a2
  77.     tst.w    d5            ; 68000? (no VBR available)
  78.     beq.s    6$
  79.     lea    getVBR(pc),a5
  80.     jsr    Supervisor(a6)        ; read VBR -> a2
  81.     move.l    #VBR_SIZE,d2
  82.     tst.b    d7            ; change it?
  83.     beq.s    6$
  84.     bsr.s    changeVBR
  85. 6$:    tst.b    d6            ; print new VBR and processor type
  86.     bne.s    exit
  87.     exg    a4,a6
  88.     move.l    a2,-(sp)
  89.     add.l    #68000,d5
  90.     move.l    d5,-(sp)
  91.     lea    vbr_info(pc),a0
  92.     move.l    a0,d1
  93.     move.l    sp,d2
  94.     jsr    VPrintf(a6)
  95.     addq.l    #8,sp
  96.     exg    a4,a6
  97. exit:    move.l    a4,a1
  98.     jsr    CloseLibrary(a6)
  99.     moveq    #0,d0
  100.     rts
  101. error:    moveq    #20,d0            ; Error!
  102.     rts
  103.  
  104.  
  105. changeVBR:
  106.     bmi.s    1$
  107.     move.l    a2,d0            ; copy VBR to $00000000
  108.     beq.s    3$            ; already there?
  109.     moveq    #0,d0
  110.     bra.s    2$
  111. 1$:    move.l    a2,a1            ; copy VBR to FAST-Ram
  112.     jsr    TypeOfMem(a6)
  113.     btst    #MEMB_FAST,d0        ; already located in FAST-Ram?
  114.     bne.s    3$
  115.     move.l    d2,d0
  116.     moveq    #MEMF_FAST|MEMF_PUBLIC,d1
  117.     jsr    AllocMem(a6)        ; allocate Fast-Ram for VBR
  118.     tst.l    d0
  119.     beq.s    3$            ; out of memory?
  120. 2$:    move.l    d0,a3
  121.     move.l    a2,a0
  122.     move.l    d0,a1
  123.     move.l    d2,d0
  124.     jsr    CopyMem(a6)
  125.     move.l    a2,-(sp)
  126.     move.l    a3,a2
  127.     lea    setVBR(pc),a5
  128.     jsr    Supervisor(a6)        ; activate new VBR
  129.     jsr    CacheClearU(a6)
  130.     move.l    (sp)+,d0
  131.     bne.s    4$
  132. 3$:    rts
  133. 4$:    move.l    d0,a1            ; free old VBR (except for Zero-VBRs)
  134.     move.l    d2,d0
  135.     jmp    FreeMem(a6)
  136.  
  137.  
  138. getVBR:
  139.     movec    VBR,a2
  140.     rte
  141.  
  142. setVBR:
  143.     movec    a2,VBR
  144.     rte
  145.  
  146.  
  147. DosName:
  148.     dc.b    "dos.library",0
  149. cmd_template:
  150.     dc.b    "ZERO/S,FAST/S,QUIET/S",0
  151. vbr_info:
  152.     dc.b    "cpu: %ld  vbr: $%08lx\n",0
  153.  
  154.     end
  155.